/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * JDialogAnalysis.java
 *
 * Created on 12/10/2010, 23:38:03
 */
package systole.view.analysis;

import java.awt.event.MouseEvent;
import org.jdesktop.application.Action;

/**
 *
 * @author jmj
 */
public class JDialogAnalysis extends javax.swing.JDialog {

    private ControllerAnalysisView controller;

    /** Creates new form JDialogAnalysis */
    public JDialogAnalysis(java.awt.Frame parent, ControllerAnalysisView controllerAnalysisView) {
        super(parent, true);
        initComponents();
        this.controller = controllerAnalysisView;
        this.jXFindBar1.setSearchable(this.jXTableAnalysis.getSearchable());        
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jMenuTable = new javax.swing.JPopupMenu();
        jMenuItemOpen = new javax.swing.JMenuItem();
        jMenuItemPrintReport = new javax.swing.JMenuItem();
        jMenuItemShowParams = new javax.swing.JMenuItem();
        jPnlCenter = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jXTableAnalysis = new org.jdesktop.swingx.JXTable();
        jPnlLeft = new javax.swing.JPanel();
        jPnlRigth = new javax.swing.JPanel();
        jPnlTop = new javax.swing.JPanel();
        jXHeader1 = new org.jdesktop.swingx.JXHeader();
        jPnlFilters = new javax.swing.JPanel();
        jXDateAnalysis = new org.jdesktop.swingx.JXDatePicker();
        jCmbPatients = new javax.swing.JComboBox();
        jCmbMedics = new javax.swing.JComboBox();
        jChkDate = new javax.swing.JCheckBox();
        jChkPatient = new javax.swing.JCheckBox();
        jChkMedic = new javax.swing.JCheckBox();
        jButton1 = new javax.swing.JButton();
        jXFindBar1 = new org.jdesktop.swingx.JXFindBar();
        jPnlButtom = new javax.swing.JPanel();
        jPnlOpen = new javax.swing.JButton();
        jPnlClose = new javax.swing.JButton();

        jMenuTable.setName("jMenuTable"); // NOI18N

        javax.swing.ActionMap actionMap = org.jdesktop.application.Application.getInstance(systole.view.SystoleApp.class).getContext().getActionMap(JDialogAnalysis.class, this);
        jMenuItemOpen.setAction(actionMap.get("open")); // NOI18N
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(systole.view.SystoleApp.class).getContext().getResourceMap(JDialogAnalysis.class);
        jMenuItemOpen.setText(resourceMap.getString("jMenuItemOpen.text")); // NOI18N
        jMenuItemOpen.setName("jMenuItemOpen"); // NOI18N
        jMenuTable.add(jMenuItemOpen);

        jMenuItemPrintReport.setAction(actionMap.get("printAnalysis")); // NOI18N
        jMenuItemPrintReport.setText(resourceMap.getString("jMenuItemPrintReport.text")); // NOI18N
        jMenuItemPrintReport.setName("jMenuItemPrintReport"); // NOI18N
        jMenuTable.add(jMenuItemPrintReport);

        jMenuItemShowParams.setAction(actionMap.get("showAnalysisParams")); // NOI18N
        jMenuItemShowParams.setText(resourceMap.getString("jMenuItemShowParams.text")); // NOI18N
        jMenuItemShowParams.setName("jMenuItemShowParams"); // NOI18N
        jMenuTable.add(jMenuItemShowParams);

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle(resourceMap.getString("Form.title")); // NOI18N
        setModal(true);
        setName("Form"); // NOI18N
        setResizable(false);

        jPnlCenter.setName("jPnlCenter"); // NOI18N
        jPnlCenter.setPreferredSize(new java.awt.Dimension(620, 500));
        jPnlCenter.setLayout(new java.awt.BorderLayout());

        jScrollPane1.setName("jScrollPane1"); // NOI18N

        jXTableAnalysis.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {},
                {},
                {},
                {}
            },
            new String [] {

            }
        ));
        jXTableAnalysis.setComponentPopupMenu(jMenuTable);
        jXTableAnalysis.setEditable(false);
        jXTableAnalysis.setName("jXTableAnalysis"); // NOI18N
        jXTableAnalysis.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jXTableAnalysisMouseClicked(evt);
            }
        });
        jScrollPane1.setViewportView(jXTableAnalysis);

        jPnlCenter.add(jScrollPane1, java.awt.BorderLayout.CENTER);

        jPnlLeft.setName("jPnlLeft"); // NOI18N
        jPnlLeft.setPreferredSize(new java.awt.Dimension(10, 222));

        javax.swing.GroupLayout jPnlLeftLayout = new javax.swing.GroupLayout(jPnlLeft);
        jPnlLeft.setLayout(jPnlLeftLayout);
        jPnlLeftLayout.setHorizontalGroup(
            jPnlLeftLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 10, Short.MAX_VALUE)
        );
        jPnlLeftLayout.setVerticalGroup(
            jPnlLeftLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 212, Short.MAX_VALUE)
        );

        jPnlCenter.add(jPnlLeft, java.awt.BorderLayout.WEST);

        jPnlRigth.setName("jPnlRigth"); // NOI18N
        jPnlRigth.setPreferredSize(new java.awt.Dimension(10, 222));

        javax.swing.GroupLayout jPnlRigthLayout = new javax.swing.GroupLayout(jPnlRigth);
        jPnlRigth.setLayout(jPnlRigthLayout);
        jPnlRigthLayout.setHorizontalGroup(
            jPnlRigthLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 10, Short.MAX_VALUE)
        );
        jPnlRigthLayout.setVerticalGroup(
            jPnlRigthLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 212, Short.MAX_VALUE)
        );

        jPnlCenter.add(jPnlRigth, java.awt.BorderLayout.EAST);

        jPnlTop.setName("jPnlTop"); // NOI18N
        jPnlTop.setPreferredSize(new java.awt.Dimension(620, 190));
        jPnlTop.setLayout(new java.awt.BorderLayout());

        jXHeader1.setName("jXHeader1"); // NOI18N
        jXHeader1.setTitle(resourceMap.getString("jXHeader1.title")); // NOI18N
        jXHeader1.setTitleFont(jXHeader1.getTitleFont().deriveFont(jXHeader1.getTitleFont().getSize()+5f));
        jPnlTop.add(jXHeader1, java.awt.BorderLayout.NORTH);

        jPnlFilters.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createLineBorder(resourceMap.getColor("jPnlFilters.border.border.lineColor")), resourceMap.getString("jPnlFilters.border.title"))); // NOI18N
        jPnlFilters.setName("jPnlFilters"); // NOI18N
        jPnlFilters.setPreferredSize(new java.awt.Dimension(550, 150));

        jXDateAnalysis.setToolTipText(resourceMap.getString("jXDateAnalysis.toolTipText")); // NOI18N
        jXDateAnalysis.setEnabled(false);
        jXDateAnalysis.setInheritsPopupMenu(true);
        jXDateAnalysis.setName("jXDateAnalysis"); // NOI18N

        jCmbPatients.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        jCmbPatients.setToolTipText(resourceMap.getString("jCmbPatients.toolTipText")); // NOI18N
        jCmbPatients.setEnabled(false);
        jCmbPatients.setInheritsPopupMenu(true);
        jCmbPatients.setName("jCmbPatients"); // NOI18N

        jCmbMedics.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        jCmbMedics.setToolTipText(resourceMap.getString("jCmbMedics.toolTipText")); // NOI18N
        jCmbMedics.setEnabled(false);
        jCmbMedics.setInheritsPopupMenu(true);
        jCmbMedics.setName("jCmbMedics"); // NOI18N

        jChkDate.setText(resourceMap.getString("jChkDate.text")); // NOI18N
        jChkDate.setName("jChkDate"); // NOI18N
        jChkDate.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                jChkDateStateChanged(evt);
            }
        });

        jChkPatient.setText(resourceMap.getString("jChkPatient.text")); // NOI18N
        jChkPatient.setName("jChkPatient"); // NOI18N
        jChkPatient.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                jChkPatientStateChanged(evt);
            }
        });

        jChkMedic.setText(resourceMap.getString("jChkMedic.text")); // NOI18N
        jChkMedic.setName("jChkMedic"); // NOI18N
        jChkMedic.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                jChkMedicStateChanged(evt);
            }
        });

        jButton1.setAction(actionMap.get("applyFilter")); // NOI18N
        jButton1.setText(resourceMap.getString("jButton1.text")); // NOI18N
        jButton1.setMaximumSize(new java.awt.Dimension(72, 23));
        jButton1.setMinimumSize(new java.awt.Dimension(72, 23));
        jButton1.setName("jButton1"); // NOI18N
        jButton1.setPreferredSize(new java.awt.Dimension(72, 23));

        javax.swing.GroupLayout jPnlFiltersLayout = new javax.swing.GroupLayout(jPnlFilters);
        jPnlFilters.setLayout(jPnlFiltersLayout);
        jPnlFiltersLayout.setHorizontalGroup(
            jPnlFiltersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPnlFiltersLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPnlFiltersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jChkDate)
                    .addComponent(jXDateAnalysis, javax.swing.GroupLayout.PREFERRED_SIZE, 144, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPnlFiltersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jChkPatient)
                    .addComponent(jCmbPatients, javax.swing.GroupLayout.PREFERRED_SIZE, 180, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPnlFiltersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPnlFiltersLayout.createSequentialGroup()
                        .addComponent(jCmbMedics, javax.swing.GroupLayout.PREFERRED_SIZE, 180, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jChkMedic))
                .addContainerGap(191, Short.MAX_VALUE))
        );
        jPnlFiltersLayout.setVerticalGroup(
            jPnlFiltersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPnlFiltersLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPnlFiltersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                    .addComponent(jChkDate)
                    .addComponent(jChkPatient)
                    .addComponent(jChkMedic))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPnlFiltersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                    .addComponent(jXDateAnalysis, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jCmbPatients, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jCmbMedics, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(34, Short.MAX_VALUE))
        );

        jPnlTop.add(jPnlFilters, java.awt.BorderLayout.CENTER);

        jXFindBar1.setName("jXFindBar1"); // NOI18N
        jXFindBar1.setSearchable(null);
        jPnlTop.add(jXFindBar1, java.awt.BorderLayout.SOUTH);

        jPnlCenter.add(jPnlTop, java.awt.BorderLayout.PAGE_START);

        getContentPane().add(jPnlCenter, java.awt.BorderLayout.CENTER);

        jPnlButtom.setName("jPnlButtom"); // NOI18N
        jPnlButtom.setPreferredSize(new java.awt.Dimension(600, 45));
        jPnlButtom.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.RIGHT, 10, 10));

        jPnlOpen.setAction(actionMap.get("open")); // NOI18N
        jPnlOpen.setText(resourceMap.getString("jPnlOpen.text")); // NOI18N
        jPnlOpen.setMaximumSize(new java.awt.Dimension(75, 23));
        jPnlOpen.setMinimumSize(new java.awt.Dimension(75, 23));
        jPnlOpen.setName("jPnlOpen"); // NOI18N
        jPnlOpen.setPreferredSize(new java.awt.Dimension(75, 23));
        jPnlButtom.add(jPnlOpen);

        jPnlClose.setAction(actionMap.get("close")); // NOI18N
        jPnlClose.setText(resourceMap.getString("jPnlClose.text")); // NOI18N
        jPnlClose.setMaximumSize(new java.awt.Dimension(75, 23));
        jPnlClose.setMinimumSize(new java.awt.Dimension(75, 23));
        jPnlClose.setName("jPnlClose"); // NOI18N
        jPnlClose.setPreferredSize(new java.awt.Dimension(75, 23));
        jPnlButtom.add(jPnlClose);

        getContentPane().add(jPnlButtom, java.awt.BorderLayout.PAGE_END);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jChkDateStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_jChkDateStateChanged
        this.jXDateAnalysis.setEnabled(this.jChkDate.isSelected());
        this.controller.setFilterChanged();
    }//GEN-LAST:event_jChkDateStateChanged

    private void jChkPatientStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_jChkPatientStateChanged
        this.jCmbPatients.setEnabled(this.jChkPatient.isSelected());
        this.controller.setFilterChanged();
    }//GEN-LAST:event_jChkPatientStateChanged

    private void jChkMedicStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_jChkMedicStateChanged
        this.jCmbMedics.setEnabled(this.jChkMedic.isSelected());
        this.controller.setFilterChanged();
    }//GEN-LAST:event_jChkMedicStateChanged

    private void jXTableAnalysisMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jXTableAnalysisMouseClicked
        if ((evt.getClickCount() == 2) && (evt.getButton() == MouseEvent.BUTTON1)) {
            this.open();
        }
    }//GEN-LAST:event_jXTableAnalysisMouseClicked
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JCheckBox jChkDate;
    private javax.swing.JCheckBox jChkMedic;
    private javax.swing.JCheckBox jChkPatient;
    private javax.swing.JComboBox jCmbMedics;
    private javax.swing.JComboBox jCmbPatients;
    private javax.swing.JMenuItem jMenuItemOpen;
    private javax.swing.JMenuItem jMenuItemPrintReport;
    private javax.swing.JMenuItem jMenuItemShowParams;
    private javax.swing.JPopupMenu jMenuTable;
    private javax.swing.JPanel jPnlButtom;
    private javax.swing.JPanel jPnlCenter;
    private javax.swing.JButton jPnlClose;
    private javax.swing.JPanel jPnlFilters;
    private javax.swing.JPanel jPnlLeft;
    private javax.swing.JButton jPnlOpen;
    private javax.swing.JPanel jPnlRigth;
    private javax.swing.JPanel jPnlTop;
    private javax.swing.JScrollPane jScrollPane1;
    private org.jdesktop.swingx.JXDatePicker jXDateAnalysis;
    private org.jdesktop.swingx.JXFindBar jXFindBar1;
    private org.jdesktop.swingx.JXHeader jXHeader1;
    private org.jdesktop.swingx.JXTable jXTableAnalysis;
    // End of variables declaration//GEN-END:variables

    /**
     * @return the jChkDate
     */
    public javax.swing.JCheckBox getjChkDate() {
        return jChkDate;
    }

    /**
     * @return the jChkMedic
     */
    public javax.swing.JCheckBox getjChkMedic() {
        return jChkMedic;
    }

    /**
     * @return the jChkPatient
     */
    public javax.swing.JCheckBox getjChkPatient() {
        return jChkPatient;
    }

    /**
     * @return the jCmbMedics
     */
    public javax.swing.JComboBox getjCmbMedics() {
        return jCmbMedics;
    }

    /**
     * @return the jCmbPatients
     */
    public javax.swing.JComboBox getjCmbPatients() {
        return jCmbPatients;
    }

    /**
     * @return the jXDateAnalysis
     */
    public org.jdesktop.swingx.JXDatePicker getjXDateAnalysis() {
        return jXDateAnalysis;
    }

    /**
     * @return the jXTableAnalysis
     */
    public org.jdesktop.swingx.JXTable getjXTableAnalysis() {
        return jXTableAnalysis;
    }

    @Action
    public void open() {
        this.controller.open();
    }

    @Action
    public void close() {
        this.controller.closeForm();
    }

    @Action
    public void showAnalysisParams() {
        this.controller.showParams();
    }

    @Action
    public void printAnalysis() {
        this.controller.printAnalysis();
    }

    @Action
    public void applyFilter() {
        this.controller.applyFilter();
    }
}
